home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: erics@access2.digex.net (Eric Simon)
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Simple inheritance Q
- Date: 27 Feb 1996 10:34:40 -0000
- Organization: UPA (a/k/a Joshua's daddy)
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: devitto@ferndown.ate.slb.com
- Message-ID: <4gumo0$hta@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: 26 Feb 1996 17:16:07 GMT
-
- I have a base class, called Animal, and a derived class, called Cat.
-
- In my main program I have:
-
- 1. Animal *p;
- 2. Cat a(args);
- 3. p = &a;
-
- Now, if I define
- class Cat:Animal{...
-
- then I get the error in line 3:
- Can not convert Cat * to Animal *
-
- But if I define
- class Cat:public Animal{...
-
- everything is fine.
-
- Can anyone tell me why?
-
- Thanks,
-
- Eric
-
- +-----------------------------------------------------------------+
- | Eric Simon | erics@access.digex.net |
- | ULTIMATE! | http://www.access.digex.net/~erics/home.html |
- +-----------------------------------------------------------------+
- | proud daddy to Joshua (4/18/93) and Eliana (3/12/95) |
- +-----------------------------------------------------------------+
-
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-